#!/bin/sh
# statis日志中,initial接口参数去重,mysql中计算guid,导入mongoDB中

if [ ! -n "$1" ]; then
cat<<HELP
Usage: ./statis_day_total_import.sh date
Example: 
    ./statis_day_total_import.sh 20120113
HELP
    exit 1
fi

PWD="/opt/wanalytics/scripts"
TOOLS=`dirname $PWD`/Tools

date_start=`date "+%s"`

mysql -h 10.103.13.103 -uroot -p1qaz2wsx3edc <<EOF

use stat;
insert into stat_day_total (pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat) select pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat from stat_day_main where date = $1;

insert into stat_day_total (pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat) select pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat from stat_day_factory where date = $1 and os_id = 61;

insert into stat_day_total (pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat) select pid,date,pv,uv,vv,register,upload,newuser,alluser,ver,operator,network,business_type,device_type,f_id,os_id,client_type,partner_mode,pid_stat from stat_day_channel where date = $1 and os_id = 61;

EOF


date_end=`date "+%s"`
time=`expr "$date_end" - "$date_start"`
echo "clientUser import take $time seconds"
